package com.epi.one.basic.generic;

/**
 * @author dxy
 * @version 1.0
 */
public class ArrayAlg {
    public static <T> T getMiddle(T... a) {
        return a[a.length / 2];
    }

    public static <T extends Number & Comparable> T min(T[] a) {
        if (a == null || a.length == 0) return null;
        T min = a[0];
        for (int i = 1; i < a.length; i++) {
            if(min.compareTo(a[i])>0) min = a[i];
        }
        return min;
    }

}
